import 'package:local_coffee/components/rgba.dart';
import 'package:flutter/material.dart';

class CustomSwitch extends StatefulWidget {
  
  ///
  final bool value;

  ///
  final Function onChange;

  ///
  /// ```
  /// @param {bool} value
  /// @param {Function} onChange
  /// ```
  CustomSwitch({
    this.value = false,
    this.onChange
  });

  @override // 这里本来是没有的
  _CustomSwitchState createState() => _CustomSwitchState(this.value);
}

class _CustomSwitchState extends State<CustomSwitch> {
  
  static bool value;

  _CustomSwitchState(bool value) {
    value = value;
  }

  @override
  Widget build(BuildContext context) {
    return Switch.adaptive(
      activeColor: RGBA.rgba88afd5,
      value: value, 
      onChanged: (flag) {
        setState(() {
          value = flag;
        });
      }
    );
  }
}